package com.wmh.baseservice.common.utils.web;

import com.wmh.baseservice.admin.entity.AdInfo;
import com.wmh.baseservice.admin.service.AdRoleService;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author 谢骏
 * @date 2023/6/20 17:01
 **/
@Component
public class UserUtil {

    @Resource
    private HttpServletRequest request;


    @Resource
    private AdRoleService adRoleService;

    public Long getId(){
        return get().getId();
    }

    public void setId(Long adId){
        request.setAttribute("adId",adId);
    }

    public void set(AdInfo adInfo){
        request.setAttribute("adInfo",adInfo);
    }

    public AdInfo get(){
        return (AdInfo) request.getAttribute("adInfo");
    }

    public boolean isSuperAdmin(){
        return adRoleService.isHasSupperAdmin(getId());
    }
}
